
summarizereg = function(regmod){
  print(" --------- Population Comparisons -----------")
  y0pred =exp( predict(regmod, newdata=d0) )
  y1pred =exp( predict(regmod, newdata=d1) )
  print(paste("Mean y(1):", mean(y1pred)))
  print(paste("Mean y(0):", mean(y0pred)))
  print(paste("ATE:", mean(y1pred) - mean(y0pred)))
  print(paste("Mean y(1)[a==1]", mean(y1pred[obsdat$a==1])))
  print(paste("Mean y(0)[a==1]", mean(y0pred[obsdat$a==1])))
  print(paste("ATT:", mean(y1pred[obsdat$a==1]) - mean(y0pred[obsdat$a==1])))
  
  print(" --------- In Sample Comparisons -----------")
  y0pred[obsdat$a==0] = exp(obsdat$y[obsdat$a==0])
  y1pred[obsdat$a==1] = exp(obsdat$y[obsdat$a==1])
  print(paste("Mean y(1):", mean(y1pred)))
  print(paste("Mean y(0):", mean(y0pred)))
  print(paste("ATE:", mean(y1pred) - mean(y0pred)))
  print(paste("Mean y(1)[a==1]", mean(y1pred[obsdat$a==1])))
  print(paste("Mean y(0)[a==1]", mean(y0pred[obsdat$a==1])))
  print(paste("ATT:", mean(y1pred[obsdat$a==1]) - mean(y0pred[obsdat$a==1])))
}


summarizereg_health = function(regmod, outcome, denominator){
  print(" --------- Population Comparisons -----------")
  h0pred = predict(regmod, newdata=d0, type="response")*1000/denominator
  h1pred = predict(regmod, newdata=d1, type="response")*1000/denominator
  print(paste("Mean h(1):", mean(h1pred)))
  print(paste("Mean h(0):", mean(h0pred)))
  print(paste("ATE:", mean(h1pred) - mean(h0pred)))
  print(paste("Mean h(1)[a==1]", mean(h1pred[obsdat$a==1])))
  print(paste("Mean h(0)[a==1]", mean(h0pred[obsdat$a==1])))
  print(paste("ATT:", mean(h1pred[obsdat$a==1]) - mean(h0pred[obsdat$a==1])))
  
  print(" --------- In Sample Comparisons -----------")
  h0pred[obsdat$a==0] = as.matrix(obsdat[obsdat$a==0, outcome])*1000/denominator[obsdat$a==0]
  h1pred[obsdat$a==1] = as.matrix(obsdat[obsdat$a==1, outcome])*1000/denominator[obsdat$a==1]
  print(paste("Mean h(1):", mean(h1pred)))
  print(paste("Mean h(0):", mean(h0pred)))
  print(paste("ATE:", mean(h1pred) - mean(h0pred)))
  print(paste("Mean h(1)[a==1]", mean(h1pred[obsdat$a==1])))
  print(paste("Mean h(0)[a==1]", mean(h0pred[obsdat$a==1])))
  print(paste("ATT:", mean(h1pred[obsdat$a==1]) - mean(h0pred[obsdat$a==1])))
}
